import axios from '@/libs/api.request';
import { getToken } from '@/libs/util';
class RoleAuthorization {
  constructor() {
    this.$axios = axios;
  }
  /**
   * 查询所有的菜单权限
   * @returns {AxiosPromise}
   */
  queryDepthChildrens = () => {
    return axios.request({
      url: '/admin/authorization/query/depthChildrens',
      method: 'get',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      }
    })
  }

  /**
   * 批量更新角色权限
   * @param param
   * @returns {AxiosPromise}
   */
  roleAuthBatchUpdate=(param)=>{
    return axios.request({
      url: '/admin/role/auth/batch/update',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 删除此角色的所有权限
   * @param param
   * @returns {AxiosPromise}
   */
  roleAuthRemove=(param)=>{
    return axios.request({
      url: '/admin/role/auth/delete',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }
  queryByRole=(param)=>{
    return axios.request({
      url: '/admin/role/auth/query/list/where',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }
}
export default RoleAuthorization;
